Telegram Group & Telegram Channel
Forwarded from Python/ django
🐍 Π—Π°Π΄Π°Ρ‡Π° ΠΏΠΎ Python: Замыкания ΠΈ области видимости

Π§Ρ‚ΠΎ Π²Ρ‹Π²Π΅Π΄Π΅Ρ‚ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠΉ ΠΊΠΎΠ΄?


def outer():
x = 5
def inner():
nonlocal x
x += 1
return x
return inner

f = outer()
print(f())
print(f())
print(f())


Π’Π°Ρ€ΠΈΠ°Π½Ρ‚Ρ‹ ΠΎΡ‚Π²Π΅Ρ‚Π°:
A)

7
8


B)

5
5


C)

6
6


D) Ошибка выполнСния

---

βœ… ΠŸΡ€Π°Π²ΠΈΠ»ΡŒΠ½Ρ‹ΠΉ ΠΎΡ‚Π²Π΅Ρ‚: A

ΠŸΠΎΡ‡Π΅ΠΌΡƒ:
Ѐункция
outer создаёт Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠ΅. ΠŸΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Π°Ρ x сохраняСтся ΠΌΠ΅ΠΆΠ΄Ρƒ Π²Ρ‹Π·ΠΎΠ²Π°ΠΌΠΈ f, ΠΏΠΎΡ‚ΠΎΠΌΡƒ Ρ‡Ρ‚ΠΎ inner β€” Π·Π°ΠΌΡ‹ΠΊΠ°Π΅Ρ‚ x ΠΈ измСняСт Π΅Ρ‘ с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ nonlocal. Π­Ρ‚ΠΎ классичСский ΠΏΡ€ΠΈΠΌΠ΅Ρ€ использования Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠΉ Π² Python.

@pythonl



tg-me.com/python_testit/1160
Create:
Last Update:

🐍 Π—Π°Π΄Π°Ρ‡Π° ΠΏΠΎ Python: Замыкания ΠΈ области видимости

Π§Ρ‚ΠΎ Π²Ρ‹Π²Π΅Π΄Π΅Ρ‚ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠΉ ΠΊΠΎΠ΄?


def outer():
x = 5
def inner():
nonlocal x
x += 1
return x
return inner

f = outer()
print(f())
print(f())
print(f())


Π’Π°Ρ€ΠΈΠ°Π½Ρ‚Ρ‹ ΠΎΡ‚Π²Π΅Ρ‚Π°:
A)

7
8


B)

5
5


C)

6
6


D) Ошибка выполнСния

---

βœ… ΠŸΡ€Π°Π²ΠΈΠ»ΡŒΠ½Ρ‹ΠΉ ΠΎΡ‚Π²Π΅Ρ‚: A

ΠŸΠΎΡ‡Π΅ΠΌΡƒ:
Ѐункция
outer создаёт Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠ΅. ΠŸΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Π°Ρ x сохраняСтся ΠΌΠ΅ΠΆΠ΄Ρƒ Π²Ρ‹Π·ΠΎΠ²Π°ΠΌΠΈ f, ΠΏΠΎΡ‚ΠΎΠΌΡƒ Ρ‡Ρ‚ΠΎ inner β€” Π·Π°ΠΌΡ‹ΠΊΠ°Π΅Ρ‚ x ΠΈ измСняСт Π΅Ρ‘ с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ nonlocal. Π­Ρ‚ΠΎ классичСский ΠΏΡ€ΠΈΠΌΠ΅Ρ€ использования Π·Π°ΠΌΡ‹ΠΊΠ°Π½ΠΈΠΉ Π² Python.

@pythonl

BY Python tests


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_testit/1160

View MORE
Open in Telegram


Python tests Telegram | DID YOU KNOW?

Date: |

Mr. Durov launched Telegram in late 2013 with his brother, Nikolai, just months before he was pushed out of VK, the Russian social-media platform he founded. Mr. Durov pitched his new appβ€”funded with the proceeds from the VK saleβ€”less as a business than as a way for people to send messages while avoiding government surveillance and censorship.

At a time when the Indian stock market is peaking and has rallied immensely compared to global markets, there are companies that have not performed in the last 10 years. These are definitely a minor portion of the market considering there are hundreds of stocks that have turned multibagger since 2020. What went wrong with these stocks? Reasons vary from corporate governance, sectoral weakness, company specific and so on. But the more important question is, are these stocks worth buying?

Python tests from ar


Telegram Python tests
FROM USA